﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using UWP.Douban.Models;
using UWP.Douban.SampleData;
using Windows.UI.Xaml.Navigation;

namespace UWP.Douban.Mvvm
{
    public class TopicDetailVm :BaseVm
    {
        private Topic _currentTopic;



        public  TopicDetailVm()
        {
            GoCommentCommand = new RelayCommand(GoCommand);
        }

     
        public ICommand GoCommentCommand { get; set; }

        public Topic CurrentTopic
        {
            get { return _currentTopic; }
            set
            {
                if (_currentTopic == value) return;
                _currentTopic = value;
                OnPropertyChanged();
            }
        }


        public async override void OnNavigatedTo(NavigationEventArgs e)
        {
            //var topics = await SampleDataUtil.GetTopics();

            //if (topics != null && topics.Any())

            CurrentTopic = e.Parameter as Topic;
            base.OnNavigatedTo(e);
        }


        private void GoCommand()
        {
            Navigate(typeof(Views.TopicCommentPage), CurrentTopic);
        }

    }
}
